

#include <gtest/gtest.h>
#include <string>
#include "../rtmp_client.h"
#include "../rtmp_connection.h"
#include "test_util.h"
TEST(RtmpClient, ParseUrl)
{
    std::string url="rtmp://127.0.0.1:1935/app/test";
    RtmpClient client(nullptr);
    client.ParseRtmpUrl(url);

    url="rtmp://127.0.0.1/app/stream";
    client.ParseRtmpUrl(url);
}

TEST(RtmpClient, Connection)
{
    /* std::string url="rtmp://127.0.0.1:1935/app/stream"; */
    std::string url = "rtmp://127.0.0.1:1935/app/test";
    Loop loop;
    RtmpClient client(&loop);
    bool result = client.ConnectionServer(url);
    EXPECT_EQ(true, result);
    if (result)
    {
        loop.AddPendingTask([&client](){
                
            INFO("execute pending task");
        });
    }
    loop.Run();
}

int main(int argc, char * argv[])
{
    testing::InitGoogleTest();
    LogModuleConfig config;
    config.m_log_level = "trace";
    config.m_file_name = argv[0];
    LogModule::Instance()->InitModule(config);
    return RUN_ALL_TESTS();
}
